<template>
  <basic-contianer>
    <avue-crud :data="tableData"
               :option="tableOption"
               @row-click="handleRowClick"
               @selection-change="selectionChange"
               @search-change="searchChange"
               ref="crud"
               :page.sync="page"
               @size-change="sizeChange"
               @current-change="currentChange"
    >
      <template slot="search">
        <el-form-item label="内容" v-if="tableOption.tag=='info'">
          <el-input placeholder="内容" size="small" v-model="searchForm.solt" />
        </el-form-item>
        <el-form-item label="关键字"  v-if="tableOption.tag=='needDeal'">
          <el-input placeholder="关键字" size="small" v-model="searchForm.solt" />
        </el-form-item>
      </template>
      <template slot-scope="scope" slot="menuLeft" v-if="tableOption.tag=='needDeal'">
        <el-button type="primary"  size="small" @click.stop="turn">转办</el-button>
        <el-button type="primary"  size="small" @click.stop="agreen">同意</el-button>
        <el-button type="danger"  size="small" @click.stop="back">退回</el-button>
        <el-button type="warning"  size="small" @click.stop="reDeal">重办</el-button>
      </template>
      <template slot-scope="scope" slot="menuLeft" v-if="tableOption.tag=='draft'">
        <el-button plain size="small" @click.stop="cleatAll">一键清空</el-button>
      </template>
    </avue-crud>
  </basic-contianer>
</template>
<script>
  export default {
    props:{
      tableData:[Array,Object],
      tableOption:[Array,Object]
    },
    data(){
      return{
        searchForm:{},
        page: {
          currentPage: 1,
          total: 100,
          layout: "prev,pager,next,total",
          background:true,
          pageSize: 10
        },
      }
    },
    computed:{

    },
    methods:{
      handleRowClick (row, event, column) {
        console.log(row, event, column)
        this.$refs.crud.rowView(row,row.$index);
      },
      selectionChange(list){
        console.log(list)
      },
      //取消选中
      toggleSelection(val){
        this.$refs.crud.toggleSelection(val);
      },
      searchChange(params) {
        console.log(this.searchForm)
      },
      sizeChange(val) {
        this.page.currentPage = 1
        this.page.pageSize = val
        this.getList()
        this.$message.success('行数' + val)
      },
      currentChange(val) {
        this.page.currentPage = val
        this.getList()
        this.$message.success('页码' + val)
      },
      clearAll(){

      },
      turn(){

      },
      agreen(){

      },
      reDeal(){

      },
      back(){

      }
    }
  }
</script>
<style lang="scss">
  .needDeal,infoAll{
    .el-table .cell{
      white-space: nowrap;
    }
  }
</style>
